home *** CD-ROM | disk | FTP | other *** search
- Path: news.iadfw.net!usenet
- From: alpet@airmail.net (bob)
- Newsgroups: comp.lang.c
- Subject: Re: writing to .exe file
- Date: Tue, 20 Feb 1996 06:53:57 GMT
- Organization: customer of Internet America
- Message-ID: <4gbkak$d42@news-f.iadfw.net>
- References: <4g961o$gdr@ultra.sonic.net>
- NNTP-Posting-Host: dal12-27.ppp.iadfw.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- Ted Rollheiser <trollhei@sonic.net> wrote:
-
- >I would like to save data ( a string ) from one run of a (dos) program
- >to the next by writing it to the .exe file. does this sound doable?
-
- Sure, programs do it all the time. Important part is to be sure space
- is allocated for your string, and that you have some marker to find
- the string. Do something like this:
-
- struct blah
- {
- char marker[10]="!@#$%%$#@!";
- char comment[80];
- }
-
- This allocats a structure in your .exe file. When your program runs,
- open the file (your .exe) in binary mode and scan for the marker.
- When you find it, you know the next 80 bytes are yours to play with.
- Modify to your hearts content. A side note is a good idea to *not*
- stop at the first occurence of your marker. It might be a fluke and
- some real code in your program may dup this marker if the you find is
- not yours, overwriting the next 80 bytes could be real bad. So go
- ahead and scan the whole file to be sure it doesn't occur again.
-
- Adam
-
-
-
-
-
-
-
-